package net.wlm.others;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class TripDetectionResult {
    private String vin;         // 车辆VIN
    private String tripId;      // 行程ID
    private long startTime;     // 开始时间(毫秒)
    private long endTime;       // 结束时间(毫秒)
    private double distance;    // 行程距离(km)[

    // 辅助方法
    public String getFormattedStartTime() {
        return formatTime(startTime);
    }

    public String getFormattedEndTime() {
        return formatTime(endTime);
    }

    public String getDuration() {
        long seconds = (endTime - startTime) / 1000;
        long hours = seconds / 3600;
        long minutes = (seconds % 3600) / 60;
        return String.format("%d小时%d分钟", hours, minutes);
    }

    private String formatTime(long timestamp) {
        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA)
                .format(new Date(timestamp));
    }

}